package com.epam.task.oop.Run;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class ItemsLoad {
   private Properties properties = new Properties();

    public void loadProperty(String pathToFile) {

        try {
            properties.load(new InputStreamReader(ItemsLoad.class
                    .getResourceAsStream(pathToFile), "UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Map<String, Integer> getProperties() {
        Map<String, Integer> productMap = new HashMap<String, Integer>();
        for (String key : properties.stringPropertyNames()) {
            String value = properties.getProperty(key);
            productMap.put(
                    value.split(";")[0],
                    (value.split(";").length > 1) ? Integer.valueOf(value
                            .split(";")[1]) : null);
        }
        return productMap;
    }

    }
